package com.wit.witmg.api;


import com.wit.witmg.service.ITMonitDustService;
import com.wit.witmg.service.ITMonitepService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 电耗监测记录表 前端控制器
 * </p>
 *
 * @author bob
 * @since 2025-09-25
 */
@RestController
@RequestMapping("monitep")
@Api(tags = "电耗监测记录表管理")
public class MonitepController {

    @Resource
    private ITMonitepService service;
    @ApiOperation("修改")
    @PostMapping("add")
    public Object add(HttpServletRequest request,
                      @RequestParam("json") String json) {
        return service.add(request,json);
    }

    @ApiOperation("查询")
    @PostMapping("get")
    public Object get(HttpServletRequest request,
                      @RequestParam(value = "dt0",required = false) Long dt0,
                      @RequestParam(value = "dt1",required = false) Long dt1,
                      @RequestParam(value = "pid",required = false) Integer pid,
                      @RequestParam(value = "sid",required = false) Integer sid) {
        return service.get(request,pid,sid,dt0,dt1);
    }

    @ApiOperation("发送命令到设备")
    @PostMapping("command")
    public Object command(
            @RequestParam("pid") Integer pid,
            @RequestParam("sid") Integer sid,
            @RequestParam(value = "command",required = false) String command ) {
        return service.sendCommandToDevice(pid.toString()+sid,command);
    }
}
